Adaptive calibration and adaptive transformation matrices for ambient light sensors

ABSTRACT

An electronic device may be provided with a display mounted in a housing. A color sensing ambient light sensor may measure the color of ambient light. The color sensing ambient light sensor may produce sensor output signals in a device-dependent color space. Control circuitry in the electronic device may convert the sensor output signals from the device-dependent color space to a device-independent color space using a color converting matrix. The color converting matrix may be determined using stored training data. The training data may include color data for different training light sources. The training data may be weighted to selectively control the influence of the training data on the color converting matrix. The training data may be weighted based on a distance between the training color data and a target color in the detected ambient light.

This application claims the benefit of provisional patent applicationNo. 62/182,083 filed on Jun. 19, 2015, which is hereby incorporated byreference herein in its entirety.

BACKGROUND

This relates generally to electronic devices, and, more particularly, tolight sensors for electronic devices.

Electronic devices such as laptop computers, cellular telephones, andother equipment are sometimes provided with light sensors. For example,ambient light sensors may be incorporated into a device to provide thedevice with information on current lighting conditions. Ambient lightreadings may be used in controlling the device. If, for example brightdaylight conditions are detected, an electronic device may increasedisplay brightness to compensate.

Ambient light conditions sometimes include significant changes in color.For example, an electronic device may be used in a cool colortemperature environment such as outdoors shade or a warm colortemperature environment such as an indoors environment that has been litwith incandescent lighting. Content that appears to be correctlydisplayed on a display in one of these environments may have anunpleasant color cast in the other environment. For example, a displaythat is properly adjusted in an outdoors environment may appear overlycool under incandescent lighting.

It would therefore be desirable to be able to improve the presentationof color images or to take other suitable actions based on ambientlighting attributes such as ambient light color information.

SUMMARY

An electronic device may be provided with a display mounted in ahousing. A color sensing ambient light sensor may measure the color ofambient light. The color sensing ambient light sensor may be mounted inalignment with an ambient light sensor window formed in an inactive areaof the display or elsewhere within the housing.

The color sensing ambient light sensor may be formed from an array oflight detectors on a semiconductor substrate. Some of the detectors mayhave spectral sensitivity profiles that fully or partly match those ofcolor matching functions. The color sensing ambient light sensor mayalso include an infrared light detector.

The color sensing ambient light sensor may produce sensor output signalsin a device-dependent color space. Control circuitry in the electronicdevice may convert the sensor output signals from the device-dependentcolor space to a device-independent color space using a color convertingmatrix. The color converting matrix may be determined using storedtraining data. The training data may include color data for differenttraining light sources. The control circuitry may weight the trainingdata to selectively control the influence of the training data on thecolor converting matrix. The training data may be weighted based on adistance between the training color data and a target color in thedetected ambient light.

BRIEF DESCRIPTION OF THE DRAWINGS

FIG. 1 is a schematic diagram of an illustrative electronic devicehaving an ambient light sensor in accordance with an embodiment.

FIG. 2 is a perspective view of a portion of an electronic devicedisplay within which an ambient light sensor has been mounted inaccordance with an embodiment.

FIG. 3 is a cross-sectional side view of an illustrative light sensorthat is being exposed to ambient light in accordance with an embodiment.

FIG. 4 is a top view of an illustrative multichannel ambient lightsensor in accordance with an embodiment.

FIG. 5 is a matrix equation that may be used to convert a sensor outputsignal from a device-dependent color space to a device-independent colorspace in accordance with an embodiment.

FIG. 6 is a graph showing how training data may be weighted based on atarget light source to adaptively determine a color converting matrixduring operation of an electronic device in accordance with anembodiment.

FIG. 7 is a flow chart of illustrative steps involved in providing anelectronic device with training data that may be used to adaptivelydetermine a color converting matrix during operation of the electronicdevice in accordance with an embodiment.

FIG. 8 is a flow chart of illustrative steps involved in determining thespectral response of individual channels in a multichannel ambient lightsensor in accordance with an embodiment.

FIG. 9 is a flow chart of illustrative steps involved in determiningtraining data based on the spectra of various representative lightsources in accordance with an embodiment.

FIG. 10 is a flow chart of illustrative steps involved in making colormeasurements with a color sensing ambient light sensor during operationof an electronic device using an adaptive color converting matrix inaccordance with an embodiment.

DETAILED DESCRIPTION

An illustrative electronic device of the type that may be provided withone or more light sensors is shown in FIG. 1. Electronic device 10 maybe a computing device such as a laptop computer, a computer monitorcontaining an embedded computer, a tablet computer, a cellulartelephone, a media player, or other handheld or portable electronicdevice, a smaller device such as a wrist-watch device, a pendant device,a headphone or earpiece device, a device embedded in eyeglasses or otherequipment worn on a user's head, or other wearable or miniature device,a television, a computer display that does not contain an embeddedcomputer, a gaming device, a navigation device, an embedded system suchas a system in which electronic equipment with a display is mounted in akiosk or automobile, equipment that implements the functionality of twoor more of these devices, or other electronic equipment.

As shown in FIG. 1, electronic device 10 may have control circuitry 16.Control circuitry 16 may include storage and processing circuitry forsupporting the operation of device 10. The storage and processingcircuitry may include storage such as hard disk drive storage,nonvolatile memory (e.g., flash memory or otherelectrically-programmable-read-only memory configured to form a solidstate drive), volatile memory (e.g., static or dynamicrandom-access-memory), etc. Processing circuitry in control circuitry 16may be used to control the operation of device 10. The processingcircuitry may be based on one or more microprocessors, microcontrollers,digital signal processors, baseband processors, power management units,audio chips, application specific integrated circuits, etc.

Input-output circuitry in device 10 such as input-output devices 12 maybe used to allow data to be supplied to device 10 and to allow data tobe provided from device 10 to external devices. Input-output devices 12may include buttons, joysticks, scrolling wheels, touch pads, key pads,keyboards, microphones, speakers, tone generators, vibrators, cameras,light-emitting diodes and other status indicators, data ports, etc. Auser can control the operation of device 10 by supplying commandsthrough input-output devices 12 and may receive status information andother output from device 10 using the output resources of input-outputdevices 12.

Input-output devices 12 may include one or more displays such as display14. Display 14 may be a touch screen display that includes a touchsensor for gathering touch input from a user or display 14 may beinsensitive to touch. A touch sensor for display 14 may be based on anarray of capacitive touch sensor electrodes, acoustic touch sensorstructures, resistive touch components, force-based touch sensorstructures, a light-based touch sensor, or other suitable touch sensorarrangements.

Input-output devices 12 may also include sensors 18. Sensors 18 mayinclude an ambient light sensor and other sensors (e.g., a capacitiveproximity sensor, a light-based proximity sensor, a magnetic sensor, anaccelerometer, a force sensor, a touch sensor, a temperature sensor, apressure sensor, a compass, a microphone or other sound sensor, or othersensors).

An ambient light sensor for device 10 may have an array of detectorseach of which is provided with a different respective color filter.Information from the detectors may be used to measure the total amountof ambient light that is present in the vicinity of device 10. Forexample, the ambient light sensor may be used to determine whetherdevice 10 is in a dark or bright environment. Based on this information,control circuitry 16 can adjust display brightness for display 14 or cantake other suitable action.

The array of colored detectors may also be used to make colormeasurements (i.e., the ambient light sensor may be a color sensingambient light sensor). Color measurements may be gathered as colorcoordinates, color temperature, or correlated color temperature.Processing circuitry may be used to convert these different types ofcolor information to other formats, if desired (e.g., a set of colorcoordinates may be processed to produce an associated correlated colortemperature, etc.). Configurations in which the color informationgathered by the ambient light sensor is a set of color coordinates aresometimes described herein as an example. This is, however, merelyillustrative. The color sensing ambient light sensor may gather anysuitable color information on ambient light. Total brightness (ambientlight intensity) may also be measured.

Color information from the color sensing ambient light sensor (and/orbrightness information) can be used to adjust the operation of device10. For example, the color cast of display 14 may be adjusted inaccordance with the color of ambient lighting conditions. If, forexample, a user moves device 10 from a cool lighting environment to awarm lighting environment (e.g., an incandescent light environment), thewarmth of display 14 may be increased accordingly, so that the user ofdevice 10 does not perceive display 14 as being overly cold. If desired,the ambient light sensor may include an infrared light sensor. Ingeneral, any suitable actions may be taken based on color measurementsand/or total light intensity measurements (e.g., adjusting displaybrightness, adjusting display content, changing audio and/or videosettings, adjusting sensor measurements from other sensors, adjustingwhich on-screen options are presented to a user of device 10, adjustingwireless circuitry settings, etc.).

A perspective view of a portion of an illustrative electronic device isshown in FIG. 2. In the example of FIG. 2, device 10 includes a displaysuch as display 14 mounted in housing 22. Housing 22, which maysometimes be referred to as an enclosure or case, may be formed ofplastic, glass, ceramics, fiber composites, metal (e.g., stainlesssteel, aluminum, etc.), other suitable materials, or a combination ofany two or more of these materials. Housing 22 may be formed using aunibody configuration in which some or all of housing 22 is machined ormolded as a single structure or may be formed using multiple structures(e.g., an internal frame structure, one or more structures that formexterior housing surfaces, etc.).

Display 14 may be protected using a display cover layer such as a layerof transparent glass, clear plastic, sapphire, or other clear layer.Openings may be formed in the display cover layer. For example, anopening may be formed in the display cover layer to accommodate abutton, a speaker port, or other components. Openings may be formed inhousing 22 to form communications ports (e.g., an audio jack port, adigital data port, etc.), to form openings for buttons, etc.

Display 14 may include an array of display pixels formed from liquidcrystal display (LCD) components, an array of electrophoretic pixels, anarray of plasma pixels, an array of organic light-emitting diode pixelsor other light-emitting diodes, an array of electrowetting pixels, orpixels based on other display technologies. The array of pixels ofdisplay 14 forms an active area AA. Active area AA is used to displayimages for a user of device 10. Active area AA may be rectangular or mayhave other suitable shapes. Inactive border area IA may run along one ormore edges of active area AA. Inactive border area IA may containcircuits, signal lines, and other structures that do not emit light forforming images. To hide inactive circuitry and other components inborder area IA from view by a user of device 10, the underside of theoutermost layer of display 14 (e.g., the display cover layer or otherdisplay layer) may be coated with an opaque masking material such as alayer of black ink. Optical components (e.g., a camera, a light-basedproximity sensor, an ambient light sensor, status indicatorlight-emitting diodes, camera flash light-emitting diodes, etc.) may bemounted under inactive border area IA. One or more openings (sometimesreferred to as windows) may be formed in the opaque masking layer of IAto accommodate the optical components. For example, a light componentwindow such as an ambient light sensor window may be formed in aperipheral portion of display 14 such as region 20 in inactive borderarea IA. Ambient light from the exterior of device 10 may be measured byan ambient light sensor in device 10 after passing through region 20 andthe display cover layer.

FIG. 3 is a cross-sectional side view of display 14 of FIG. 2 takenalong line 24 and viewed in direction 25 of FIG. 2. As shown in FIG. 3,light sensor 26 may be mounted in alignment with window 20. Window 20may have a circular shape, a square shape, a shape with curved and/orstraight edges, a circular ring shape with a central opaque region, orany other suitable shape. Light sensor 26 may be a color sensing ambientlight sensor that is used in measuring ambient light in the vicinity ofdevice 10. As shown in FIG. 3, display 14 may have an outermost layersuch as display cover layer 30. Display cover layer 30 has an outersurface such as surface 34. Rays of ambient light are characterized byvarious angles of incidence A.

Window 20 may be formed from an opening in opaque masking layer 28 oninner surface 32 of display cover layer 30 in inactive area IA. Layer 30may be formed from glass, plastic, ceramic, sapphire, or othertransparent materials and may be a part of a display module for display14 or may be a separate protective layer that covers active displaystructures. The opening associated with window 20 may be filled withoptical structures such as ambient light sensor ink 54 and lightredirecting structures 56.

Ambient light sensor ink 54 may have sufficient transparency at visibleand infrared wavelengths to allow sensor 26 to operate, while at thesame time enhancing the outward appearance of window 20 (e.g., by partlyobscuring the presence of window 20 to a user of device 10 by makingwindow 20 have a visual appearance that is not too dissimilar from theportion of layer 30 that includes layer 28). If desired, ambient lightsensor ink 54 may be omitted.

Sensor 26 may have multiple light detectors 60 (e.g., photodiodes,phototransistors, or other semiconductor photodetector structures).Light detectors 60 may be formed in an array on a common semiconductorsubstrate such as substrate 62 or may be formed using two or moresubstrates. Each of light detectors 60 may be provided with acorresponding color filter 58. To provide sensor 26 with the ability toaccurately measure colors, sensor 26 may include two or more detectors60 (e.g., 2-10 detectors, 3-8 detectors, 4-7 detectors, 5-7 detectors,only 4 detectors or more than 4 detectors, only 5 detectors or more than5 detectors, only 6 detectors or more than 6 detectors, only 7 detectorsor more than 7 detectors, only 8 detectors or more than 8 detectors,fewer than 8 detectors, or any other suitable number of detectors).Filters 58 may be thin-film interference filters and/or may be coloredlayers of polymer or other color filter elements (e.g., colored filtersformed from dyes and/or pigments).

Light redirecting structures 56 may be used to gather light from avariety of angles of incidence and to effectively pass this light tosensor 26. Light redirecting structures 56 may include structures suchas diffusers and/or patterned lenses to help redirect off-axis ambientlight rays into sensor 26 at an angle that is close to perpendicular tothe surface of substrate 62, thereby reducing the dependence of ambientlight readings on the relative orientation between device 10 and thesources of ambient light.

To allow sensor 26 to make color measurements, sensor 26 may have anarray of light detectors 60, each of which may have a different spectralprofile for gathering light. In the example of FIG. 4, there are sixvisible light detectors 60 (PD1, PD2, PD3, PD4, PD5, and PD6) and oneinfrared light detector PD7. This is merely illustrative. For example,there may be fewer than six (e.g., five, four, or three or fewer.) ormore than six (e.g., seven, eight, or more than eight) visible lightdetectors. Infrared light detector PD7 may be omitted or infrared lightdetection capabilities may be provided by extending the long wavelengthsensitivity of a red detector so that the red detector has a spectralsensitivity profile that overlaps near infrared wavelengths. As anexample, PD7 may be omitted and PD6 may be a red light detector with anextended spectral profile that is sensitive at infrared wavelengths. Inthis type of configuration, the IR response of PD6 may be used to helpdiscriminate between different types of light sources (e.g., IR ornon-IR, etc.) and may provide a visible spectral profile contribution(e.g., red sensitivity) to sensor 26 that helps sensor 26 measure thecolor of ambient light.

In one illustrative arrangement, PD1 may have a blue spectral response,detector PD6 may have a red spectral response, and the spectralresponses of detectors PD2, PD3, PD4, and PD5 may cover respectivewavelength ranges between the blue and red ends of the visible spectrum.Detector PD7 may cover infrared wavelengths (e.g., wavelengths includingwavelengths above 700 nm, between 800-900 nm, etc.). This is, however,merely illustrative. If desired, detectors 60 may have other spectralresponses.

To enhance color sensing accuracy, it may be desirable to configure thespectral responses of detectors 60 so that one or more of detectors 60has a spectral response that matches a color matching function (e.g.,one of the three CIE standard observer color matching functions x, y,and z). The color matching functions represent the spectral response ofa standard observer. For example, the spectral response of detector PD1may partially or fully match the spectral shape of color matchingfunction z, the spectral response of detector PD3 may partially or fullymatch the spectral shape of color matching function y, and the spectralresponse of detector PD4 may partially or fully match the spectral shapeof color matching function x.

In addition to the spectral responses of detectors 60 that match thecolor matching functions, detectors 60 may cover other spectral ranges(e.g., ranges that partly overlap other the coverage ranges of otherdetectors and that help provide coverage over the entire visiblespectrum), thereby enhancing color measurement accuracy. At the sametime, the use of an excessive number of different detectors may beavoided to avoid excessive cost, complexity, and power consumption.Readings from infrared detector PD7 may be used to enhance accuracy forvisible light detection (e.g., by removing infrared contributions to thevisible light detectors) and/or may be used to help allow sensor 26 todiscriminate between different types of lighting source. As an example,light sources with little or no infrared (IR) light may be characterizedas non-IR sources, whereas light sources that contain significant lightdetected by detector PD7 may be characterized as IR sources.

The output of light sensor 26 may be dependent on the spectralsensitivities of detectors 60 in light sensor 26. Because spectralsensitivity can vary from sensor to sensor, the output signals fromsensor 26 may be device-dependent (e.g., the output signals may bevalues in a device-dependent color space). Thus, to accurately measurethe color and brightness of ambient light, control circuitry 16 mayconvert the device-dependent output signals of light sensor 26 to adevice-independent color space. FIG. 5 shows a matrix equation in whichcolor converting matrix T is used to convert device-dependent sensoroutput values PD1 . . . PD6 to a device-independent color space (e.g.,CIE XYZ). In the example of FIG. 5, sensor 26 has six visible lightsensors, so the sensor output matrix includes one column of six detectoroutputs PD1 . . . PD6. Detector outputs PD1 . . . PD6 may be obtainedwhen sensor 26 is exposed to ambient light (e.g., when device 10 isbeing used by a user). Detector outputs may be values associated with asensor-dependent color space. For example, detector outputs may be red,green, and blue (RGB) values in a red-green-blue color space, may bered, green, blue, and clear/white values in a red-green-blue-clear orred-green-blue-white color space, or may be values in another suitabledevice-dependent color space. When color converting matrix T is appliedto sensor output values PD1 . . . PD6, the ambient light data may beconverted to a device-independent color space and may be represented bytristimulus values X, Y, and Z. The example of FIG. 5 in which sensoroutput data is converted to the CIE XYZ color space is merelyillustrative. If desired, sensor output data may be converted to anyother suitable device-independent color space.

In conventional electronic devices, a fixed color converting matrix isused to map light sensor RGB values to CIE XYZ tristimulus values.However, the same color converting matrix may not be appropriate for allambient lighting conditions. For example, one color converting matrixmay accurately map colors to a device-independent color space in a firstambient lighting condition, but may inaccurately map colors to adevice-independent color space in a second ambient lighting condition,leading to inaccurate measurements of the color and brightness ofambient light.

To accurately convert sensor output data to a device-independent colorspace, matrix T of FIG. 5 may be adaptive. For example, in addition toor rather than storing a fixed color converting matrix in device 10 tobe used for all ambient lighting conditions, matrix T may be adaptivelydetermined during operation of device 10 based on ambient lightingconditions.

To enable on-the-fly computing of color converting matrix T, device 10may store training data that contains information about different typesof representative light sources (sometimes referred to as training lightsources). The training data may be gathered during calibrationoperations and may indicate a relationship between the device-dependentspectral response of sensor 26 and the device-independent colorinformation associated with the different light sources. Thisinformation may be stored in electronic device 10 (e.g., using controlcircuitry 16).

FIG. 6 is a diagram showing illustrative training data that may bestored in electronic device 10. The graph of FIG. 6 shows training datasuch as data points 66 in a three-dimensional color space (e.g., asensor-dependent RGB color space, as an example). For each data point66, device 10 may store device-independent color data (e.g., X, Y, and Ztristimulus values, a luminance value Y and chromaticity coordinates xand y, or other suitable device-independent color data) anddevice-dependent color data (e.g., an RGB value including a red, green,and blue value, an RGBC value including a red, green, blue, and clearvalue, or other suitable value in sensor-dependent color space). Eachdata point 66 may correspond to a different light source. For example,each data point 66 may correspond to the RGB response of light sensor 60for a given light source having XYZ color data. By storing both the RGBresponse information and the XYZ color information associated with thelight source that produces the RGB response, control circuitry 16 maydetermine a color converting matrix for a given light source using arearranged version of the equation of FIG. 5 (e.g., by multiplying amatrix containing the XYZ color data with the pseudoinverse of a matrixcontaining the RGB response information).

When making color measurements with sensor 26 while a user is usingdevice 10, device 10 may use information on which type of ambient lightsource is present (sometimes referred to as a target light source) todetermine which sensor calibration data should be used in processingsensor measurements (e.g., which data points 66 should be used todetermine color converting matrix T).

In some scenarios, for example, it may be desirable to target aparticular light source or group of light sources rather than weightingall training light sources associated with data points 66 equally. Toselectively control the influence of the training light sources indetermining the color of a given light source, control circuitry 16 maydetermine a weighting function that weights the training data based onthe distance between the data and a target light source in a given colorspace.

As shown in FIG. 6, control circuitry 16 may determine a target lightsource represented by point 64 in a suitable color space (e.g., adevice-dependent color space such as a red-green-blue color space).Training data 66 that is further from the target light source data 64may be weighted less than training data 66 that is closer to the targetlight source data 64. For example, training data 66 in region 68 may begiven the highest weights, training data 66 in region 70 may be giventhe next highest weights, training data 66 in regions 72 may be giventhe lowest weights, etc., where regions 68, 70, and 72 are concentricspherical regions centered around target point 64. In this way, controlcircuitry 16 may determine a color converting matrix T that not onlyaccounts for the spectral response of sensor 26 but also one that can beadjusted to target a particular color or light source in the ambientlight.

FIG. 7 is a flow chart of illustrative steps involved in providingelectronic device 10 with a training dataset that control circuitry 16may use to adaptively determine a color converting matrix for mappingsensor data to device-independent color data.

At step 100, calibration computing equipment may determine the spectralsensitivity of sensor 26. This may include, for example, gatheringsensor data from photodetectors 60 of light sensor 26 while exposinglight sensor 26 to different light sources having known spectral powerdistributions. Step 100 is described in greater detail below inconnection with FIG. 8.

At step 102, the calibration computing equipment may determine atraining dataset using representative light sources and using thespectral sensitivity of the sensor (determined in step 100). This mayinclude, for example, determining the color of each representative lightsource in a device-independent color space (e.g., determining the XYZtristimulus values of each light source) and determining a sensorresponse for each light source in sensor-dependent color space (e.g.,RGBC color space or other suitable color space). Step 102 is describedin greater detail below in connection with FIG. 9

At step 104, the training dataset may be stored in device 10 (e.g.,using control circuitry 16).

FIG. 8 is a flow chart of illustrative steps involved in performing step100 of FIG. 7 to determine the spectral response of light sensor 26.

At step 200, calibration computing equipment may expose light sensor 26to a variety of light sources with known spectra (e.g., with knownspectral power distributions). For example, a first light source mayhave a spectrum S1(λ), a second light source may have a spectrum S2(λ),etc.

At step 202, the calibration computing equipment may gather sensoroutputs from sensor 26 while sensor 26 is exposed to the variety oflight sources. For example, a first photodetector 60 may produce asensor output PD1 _(L1) for a first light source, PD1 _(L2) for a secondlight source, etc. If light source 26 is exposed to m light sources,calibration computing equipment may gather m sensor outputs from eachdetector 60 in light sensor 26. The sensor outputs may be valuesassociated with a sensor-dependent color space. For example, detectoroutputs may be red, green, and blue (RGB) values in a red-green-bluecolor space, may be red, green, blue, and clear/white values in ared-green-blue-clear or red-green-blue-white color space, or may bevalues in another suitable device-dependent color space.

At step 204, the calibration computing equipment may determine thespectral response of each detector 60 in light sensor 26 using the knownspectral power distributions of the light sources and the sensor outputvalue for each light source. Assuming that the sensor output values areequal to the product of the spectral power distribution of a lightsource and the spectral sensitivity of the light sensor, calibrationcomputing equipment may use an optimization technique or an inversematrix technique to recover the spectral sensitivity of the lightsensor.

FIG. 9 is a flow chart of illustrative steps involved in performing step102 of FIG. 7 to determine a training dataset for light sensor 26.

At step 300, calibration computing equipment may determine the spectraof various training light sources (e.g., n light sources). This mayinclude, for example, using a reference spectroradiometer, spectroscope,or spectrometer to make color measurements on the selected lightsources. For example, the spectroradiometer may measure the spectralpower distribution of each light source. If desired, the training lightsources used may be selected to avoid having light sources with verysimilar spectral power distributions. This is, however, merelyillustrative. If desired, light sources with similar spectral powerdistributions may be used.

If desired, training light sources with known spectral powerdistributions may be used and the measurement step (step 300) may beomitted.

At step 302, the calibration computing equipment may compute a lightsource color data matrix A for each light source based on the spectralpower distribution of the light source (determined in step 300) andcolor matching functions (e.g., the CIE color matching functions x, y,and z. The color data in the color data matrix may be computed bymultiplying the spectral power distribution of each light source(determined in step 300) with the color matching functions x, y, and zto obtain tristimulus values X, Y, and Z. Each column of the lightsource color data matrix A may contain the XYZ tristimulus values for agiven training light source. For example, a first column of matrix A mayinclude the XYZ tristimulus values associated with a first traininglight source, a second column may include the XYZ tristimulus valuesassociated with a second training light source, etc.

At step 304, the calibration computing equipment may compute a sensorresponse matrix S based on the spectra of the n light sources. Thesensor response information in the sensor response matrix may becomputed by multiplying the spectral power distribution of each lightsource (determined in step 300) with the spectral response of each lightdetector (determined using the process of FIG. 8). Each column of thesensor response matrix S may include a sensor output value for eachphotodetector 60 in ambient light sensor 26. For example, a first columnmay include values PD11, PD21, PD31, etc., indicating each photodetectorresponse for a first training light source, a second column may includevalues PD12, PD22, PD32, etc., indicating each photodetector responsefor a second light source, etc.

At step 306, the calibration computing equipment may store the lightsource color value matrix A and the light sensor response matrix S indevice 10. This may include, for example, storing a calibration filehaving the following columns, with each row representing data for adifferent training light source: luminance of training light source,chromaticity coordinates of training light source, sensor output for PD1(e.g., red channel), PD2 (e.g., blue channel), PD3 (e.g., greenchannel), PD4 (e.g., clear or white channel).

A device having a sensor that has been calibrated using this type ofcalibration scheme may be operated in accordance with the flow chart ofFIG. 10.

At step 400, device 10 may be exposed to ambient light having a givenspectrum. When exposed to the input light, sensor 26 will produce anoutput that can be gathered by device 10 and stored (e.g., using controlcircuitry 16).

After gathering the detector output signals from sensor 26 at step 400,device 10 may, at step 402, identify which type of light source iscurrently being used to illuminate device 10. For example, if IRdetector PD7 detects that more than a predetermined amount of infraredlight is present relative to the total ambient light reading, thecurrent lighting conditions can be characterized as falling within theIR lighting type. If there is no IR light present (i.e., if the IRsignal is less than a predetermined amount relative to the other typesof light), the lighting source can be characterized as being one of thenon-IR types.

After gathering sensor readings from sensor 26 and identifying a targetlight source, control circuitry 16 may determine an appropriateweighting matrix to apply to the training data based on the target lightsource. The waiting matrix may, for example, be a matrix having nweighting values on the diagonal and zeroes elsewhere. The weightingfunction W may be calculated as follows:

$\begin{matrix}{W = \begin{bmatrix}w_{1} & 0 & \ldots & 0 \\0 & w_{2} & \ldots & 0 \\\vdots & \vdots & \ddots & 0 \\0 & 0 & \ldots & w_{n}\end{bmatrix}} & (1) \\{w_{i} = {1\text{/}\left( {\sqrt{\left( {R_{t} - R_{i}} \right)^{2} + \left( {G_{t} - G_{i}} \right)^{2} + \left( {B_{t} - B_{i}} \right)^{2} + \left( {C_{t} - C_{i}} \right)^{2}} + c} \right)}} & (2)\end{matrix}$

where c is a small constant (e.g., 0.001), R_(t), G_(r), B_(t), C_(t)represent the target light source data in sensor space (e.g., data point64 of FIG. 6), and R_(i), G_(i), B_(i), and C_(i), represent the i^(th)training light source (e.g., one of data points 66 of FIG. 6). Using theweighted version of the ordinary least squares approach allows controlcircuitry 16 to vary the influence of training data on formation of thetransformation matrix T. As equation (2) shows, a larger distancebetween a given target light source and a light source in the trainingdataset leads to a decreased weight in matrix W, thereby reducing theinfluence that the training light source has on the construction of thetransformation matrix T.

The method described above in which the weighting values in theweighting matrix W are determined based on Euclidean distances betweeneach of the training light sources and a target light source in a givencolor space is merely illustrative. If desired, other metrics such asangular distance (e.g., cosine distance) may be used to determine theweighting values w_(i) of matrix W. Using the angular distance metric,weighting values w_(i) may be determined using the following equation:w _(i)=1/(d ^(p)+ε)  (3)

where p=1, 2, 3, . . . ; where d is the cosine distance between a firstvector representing the target light source (e.g., data point 64 of FIG.6) and a second vector representing the i^(th) training light source(e.g., one of data points 66 of FIG. 6); and where ε is an arbitrarilysmall positive quantity. In general, any suitable metric that can beused to compute the pairwise distance between pairs of vectors may beused for determining the distance between the target light source andeach training light source in a given color space. Euclidean distanceand cosine distance metrics are merely illustrative examples.

At step 406, control circuitry 16 may determine an adapted colorconverting matrix T based on the weighting matrix W (step 404), thestored sensor response matrix S (step 304 of FIG. 9), and the lightsource color value matrix A (step 302 of FIG. 9) using the followingequation:T=A×W×S ^(T)×(S×W×S ^(T))⁻¹  (4)

At step 408, the color of the measured ambient light indevice-independent color space (e.g., the XYZ tristimulus values of themeasured ambient light) can be determined by multiplying the measuredsensor output by the adapted color converting matrix T. If desired,ambient light sensor color information from sensor 26 may be gathered orconverted to produce color temperature data, correlated colortemperature data, color coordinates, or other color information inaddition to or instead of tristimulus values. The use of sensor 26 tomake color measurements that are stored as color coordinates is merelyillustrative. Any color ambient light information (and intensityinformation) may be gathered and used by device 10, if desired.

Device 10 may use control circuitry 16 to take suitable action based onthe measured color of the ambient light (and, if desired, based on lightintensity). For example, device 10 may adjust the color of the imagesbeing displayed on display 14, may make other adjustments to display 14,etc.

The foregoing is merely illustrative and various modifications can bemade by those skilled in the art without departing from the scope andspirit of the described embodiments. The foregoing embodiments may beimplemented individually or in any combination.

What is claimed is:
 1. An electronic device that is exposed to ambientlight that has an ambient light color, comprising: a color sensingambient light sensor that detects the ambient light and that produces acorresponding sensor output signal; and control circuitry thatdetermines a target color based on the sensor output signal and thatadaptively determines a color converting matrix based on the detectedambient light, wherein the control circuitry stores data correspondingto a plurality of different light sources, wherein the control circuitrycomputes each value in the color converting matrix during operation ofthe electronic device based on a distance between each light source andthe target color in a given color space, wherein the control circuitryconverts the sensor output signal from a sensor signal in adevice-dependent color space to a sensor signal in a device-independentcolor space using the color converting matrix to obtain an ambient lightcolor value indicative of the ambient light color, wherein thedevice-dependent color space is defined by red, green, and blue values,and wherein the device-independent color space is defined by tristimulusvalues.
 2. The electronic device defined in claim 1 wherein the colorsensing ambient light sensor has at least six light detectors eachhaving a respective spectral sensitivity profile.
 3. The electronicdevice defined in claim 1 further comprising a display that displaysimages for a user, wherein the control circuitry adjusts the display atleast partly based on the ambient light color value.
 4. The electronicdevice defined in claim 1 wherein the control circuitry weights the databased on the target color.
 5. The electronic device defined in claim 1wherein the control circuitry weights the data by determining aweighting value for each light source based on how close the lightsource is to the target color, and wherein the color converting matrixis determined based on the weighting values.
 6. The electronic devicedefined in claim 1 wherein the light sensor includes a red channel, agreen channel, a blue channel, and a clear channel.
 7. The electronicdevice defined in claim 1 wherein the color sensing ambient light sensorhas a semiconductor substrate and has at least five light detectors inthe semiconductor substrate each having a respective spectralsensitivity profile.
 8. The electronic device defined in claim 7 furthercomprising an infrared light sensor in the semiconductor substrate.
 9. Amethod for operating an electronic device having a color sensing ambientlight sensor and control circuitry, comprising: with the color sensingambient light sensor, producing a sensor output signal in response toreceiving ambient light; and with the control circuitry, determining atarget color based on the sensor output signal, computing a colorconverting matrix based on the target color, and converting the sensoroutput signal from a sensor signal in a first color space to a sensorsignal in a second color space using the color converting matrix,wherein computing the color converting matrix comprises computing eachvalue in the color converting matrix during operation of the electronicdevice based on a distance between a plurality of light sources and thetarget color in the first or second color space, and wherein convertingthe sensor output signal comprises multiplying the sensor output signalwith the color converting matrix.
 10. The method defined in claim 9wherein converting the sensor output signal from the first color spaceto the second color space comprises converting the sensor output signalfrom a device-dependent color space to a device-independent color space.11. The method defined in claim 9 wherein the control circuitry storestraining data comprising a plurality of color values, each color valuecorresponding to an associated one of the light sources, the methodfurther comprising: determining a difference between the target colorand each of the color values.
 12. The method defined in claim 11 furthercomprising: determining a weighting value for each stored color valuebased on the difference between the target color and that stored colorvalue.
 13. The method defined in claim 12 wherein computing the colorconverting matrix comprises computing the color converting matrix basedon the weighting values.
 14. A method for calibrating a color sensingambient light sensor in an electronic device, wherein the electronicdevice comprises control circuitry and wherein the color sensing ambientlight sensor comprises a plurality of photodetectors with differentspectral responses, the method comprising: gathering spectral responsedata from the color sensing ambient light sensor; gathering spectralpower distribution data for a plurality of light sources; processing thegathered spectral response data and the gathered spectral powerdistribution data to produce a first set of data corresponding to sensoroutput values for each of the light sources in a first color space and asecond set of data corresponding to color values for each of the lightsources in a second color space, wherein the first color space is adevice-dependent color space defined at least in part by red values,green values, and blue values, and wherein the second color space is adevice-independent color space defined at least in part by chromaticitycoordinates; and storing the first and second sets of data in theelectronic device, wherein the control circuitry is configured todetermine a target color based on an output signal from the colorsensing ambient light sensor, compute each value of a color convertingmatrix during operation of the electronic device based on a distancebetween the target color and each of the color values in the first orsecond color space, and apply the color converting matrix to the outputsignal from the color sensing ambient light sensor.
 15. The methoddefined in claim 14 wherein processing the gathered spectral responsedata and the gathered spectral power distribution data comprisesmultiplying the spectral power distribution data by the spectralresponse data to obtain the first set of data.
 16. The method defined inclaim 15 wherein processing the gathered spectral response data and thegathered spectral power distribution data comprises multiplying thespectral power distribution data by a set of color matching functions toobtain the second set of data.